<?php

namespace app\admin\service\statistics\traits;

use app\admin\service\statistics\filters\ChainFilter;

/**
 * Trait FilterChainTrait
 * @package app\admin\service\statistics\traits
 */
trait FilterChainTrait
{

    /**
     * 实现链路筛选
     * @param \think\db\Query $query
     * @param ChainFilter $filter
     * @return void
     */
    protected function filterByChainFilter($query, ChainFilter $filter): void
    {
        $chains = $filter->getChains();

        if (!empty($chains)) {

            $query->whereIn('chain', $chains);
        }

    }
}